﻿namespace EyeOpen.CascadingDropDown.Web
{
	using System;
	using System.Data;
	using System.Web.UI;
	using EyeOpen.Data;
	using EyeOpen.Web;

	public partial class Edit : Page
	{
		protected override void OnLoad(System.EventArgs e)
		{
			var customer =
				((DataView)customerSqlDataSource.Select(DataSourceSelectArguments.Empty))[0];

			if (IsPostBack)
			{
				return;
			}

			customerTextBox.Text = customer.Field("Name");
			customerHiddenField.Value = customer.Field<Guid>("Id").ToString();

			cityDropDownList.SelectByText(customer.Field("City"));
			townDropDownList.SelectByText(customer.Field("Town"));
		}

		protected void Save(object sender, EventArgs e)
		{
			updateCustomerSqlDataSource.Update();
		}
	}
}